<?php

namespace App\Console\Commands\Tasks;
use App\Http\Controllers\Common\TaskController;
use Carbon\Carbon;
use Illuminate\Console\Command;

class RefreshHotListCommand extends Command
{
    //命令名
    protected $signature = 'task:refresh-hot-list';

    //命令描述:刷新热门推荐列表
    protected $description = 'refresh hot list';

    public function __construct()
    {
        parent::__construct();
    }

    //业务处理
    public function handle()
    {
        $nowTime = Carbon::create();
        $nowMin = $nowTime->copy()->minute;
        $targetMin = floor($nowMin / 5) * 5 + 5;
        $resultTime = $nowTime->copy()->startOfMinute()->addMinutes($targetMin - $nowMin);
        $resultMin = $resultTime->format("YmdHi");

        (new TaskController())->refreshRoomPopularity($resultMin, $this);

        (new TaskController())->refreshHotList($resultMin, $this);
    }

}
